<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>

<form:form commandName="datebean" cssClass="form-horizontal" role="form" onsubmit="false">
	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title">基本信息</h3>
		</div>
		<div class="panel-body">
			<div class="col-sm-12">
				<div class="form-group">

					<label class="col-sm-2 control-label no-padding-right" for="name">姓名<font color="red">*</font></label>
					<div class="col-sm-3">
						<input type="text" name="name" id="name" placeholder="请输入姓名" value="${datebean.name}" class="form-control required">
					</div>

					<label class="col-sm-2 control-label no-padding-right" for="username">用户名<font color="red">*</font></label>
					<div class="col-sm-3">
						<input type="text" name="username" id="username" readonly="readonly" placeholder="请输入姓名" value="${datebean.username}" class="form-control ">
					</div>
				</div>
				

				<div class="form-group">
					<label class="col-sm-2 control-label no-padding-right" for="gender">性别</label>
					<div class="col-sm-3">
						<form:select path="gender" items="${redis:getDictList('Gender',false)}" itemValue="basId" itemLabel="name" cssClass="form-control"></form:select>
					</div>
				
			<%--		<label class="col-sm-2 control-label no-padding-right" for="birthday">出生日期</label>
					<div class="col-sm-3">
						<div class="row">
							<div class="col-xs-8 col-sm-12">
								<div class="input-group">
									<input type="text" name="birthday" id="birthday"  class="form-control date-picker"  readonly value="${datebean.birthday}" />
									<span class="input-group-addon">
										<i class="fa fa-calendar bigger-110"></i>
									</span>
								</div>
							</div>
						</div>
					</div>--%>
					
				</div>

				<div class="form-group">

					<label class="col-sm-2 control-label no-padding-right" for="money">余额</label>
					<div class="col-sm-3">
						<input type="text" name="money" id="money" placeholder="" value="${datebean.money}" class="form-control ">
					</div>
				</div>
				
				<div class="form-group">
					<%--<label class="col-sm-2 control-label no-padding-right" for="nativeAddr">籍贯</label>
					<div class="col-sm-3">
						<input type="text" name="nativeAddr" id="nativeAddr" placeholder="籍贯" value="${datebean.nativeAddr}" class="form-control ">
					</div>--%>
					
					<label class="col-sm-2 control-label no-padding-right" for="password">密码<font color="red">*</font></label>
					<div class="col-sm-3">
						<input type="password" name="password" id="password" placeholder="请输入密码" value="${datebean.password}" class="form-control required">
					</div>
				</div>
				
				<div class="form-group">
					<%--<label class="col-sm-2 control-label no-padding-right" for="email">邮箱</label>
					<div class="col-sm-3">
						<input type="text" name="email" id="email" placeholder="请输入邮箱" value="${datebean.email}" class="form-control ">
					</div>--%>

					<label class="col-sm-2 control-label no-padding-right" for="mobile">手机号码</label>
					<div class="col-sm-3">
						<input type="text" name="mobile" id="mobile" placeholder="请输入手机号码" value="${datebean.mobile}" class="form-control ">
					</div>
				</div>
			
				<div class="form-group">
					<label class="col-sm-2 control-label no-padding-right" for="deptId">部门</label>
					<div class="col-sm-3">	
						<form:select path="deptId" items="${depts }" itemValue="sysId" itemLabel="deptName" cssClass="form-control"></form:select>
					</div>

					<label class="col-sm-2 control-label no-padding-right" for="roleId">角色</label>
					<div class="col-sm-3">
						<form:select path="roleId" items="${redis:getDictList('Position',false)}" itemValue="basId" itemLabel="name" cssClass="form-control"></form:select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label no-padding-right" for="avatar">头像</label>
					<div class="col-sm-3">
						<img id="avatar" class="editable img-responsive" alt="Alex's Avatar" src="<s:url value="${datebean.imageUrl}"></s:url>" />
					</div>

					<input type="file"  id="fileimg" />
					<input type="button" value="Upload" id="uploadBtn"  />


				</div>
			</div>
		</div>
	</div>
	<input type="hidden" name="floorId" value="${datebean.floorId}">
	<input  name="userId" type="hidden" value="${datebean.userId}">
	<input  name="image"  type="hidden" id ="image" value="${datebean.imageUrl}">
</form:form>
		<script type="text/javascript">
			jQuery(function($) {
				$('.date-picker').datepicker({
					inline: true,
					format:"yyyy-mm-dd",
					autoclose: true,
					todayHighlight: true,
					language: 'cn'
				})
				//show datepicker when clicking on the icon
				.next().on(ace.click_event, function(){
					$(this).prev().focus();
				});

				$("#uploadBtn").click(function () {
					console.log("kaishile==============")
					var fileinp= $('#fileimg')[0];
					var file = fileinp.files[0];
					var formData = new FormData();
					console.log("fileinp",fileinp);
					console.log("file",file);
					console.log("formData",formData);
					if(file){
						formData.append('files',file);
						console.log("data",formData);

						$.ajax({
							url:'/pictureUpload/uploadBatch',
							type:'POST',
							data: formData,
							contentType: false, // 必须false才会自动加上正确的Content-Type
							processData: false, // 必须false才会避开jQuery对formdata的默认处理
							cache: false,
							success: function(data) {
								// 上传成功后的处理
								console.log(data.data);
								$("#image").attr("value",data.data[0].sysId);
								console.log("fileImg's value",$("#image").val())
								alert(data.data);
							},
						})

					}else {
						console.log("没有文件")
					}

				})
		/*		$("#uploadBtn").click(function() {
					console.log("kaishile==============")
					var formData = new FormData($('#fileimg')[0]); // 使用 FormData 对象包装表单数据
					console.log("file",formData)
					$.ajax({
						url:'/pictureUpload/uploadBatch',
						type:post,
						data: formData,
						contentType: false, // 必须false才会自动加上正确的Content-Type
						processData: false, // 必须false才会避开jQuery对formdata的默认处理
						success: function(data) {
							// 上传成功后的处理
							console.log(data);
							alert('Upload success!');
						},
					})
				});*/

			});

		/*	jQuery(function ($) {

				$("#uploadBtn").click(function() {
					console.log("kaishile==============")
					var formData = new FormData($('#fileimg')[0]); // 使用 FormData 对象包装表单数据
					console.log("file",formData)
					$.ajax({
						url:'/pictureUpload/uploadBatch',
						type:post,
						data: formData,
						contentType: false, // 必须false才会自动加上正确的Content-Type
						processData: false, // 必须false才会避开jQuery对formdata的默认处理
						success: function(data) {
							// 上传成功后的处理
							console.log(data);
							alert('Upload success!');
						},
					})
				});
			})
*/






		</script>